/**
 * 提示
 * 加载
 * 确认
 * */

export default class Tips {
  
  static success (title, duration = 500, mask = false) {
    wx.showToast({
      title: title,
      duration: duration,
      mask: mask
    })
  }
  
  static error (title, duration = 500, mask = false) {
    wx.showToast({
      title: title,
      icon: 'none',
      duration: duration,
      mask: mask
    })
  }
  
  static hideToast () {
    wx.hideToast()
  }
  
  static model (title, content, showCancel = true, cancelText = '取消', confirmText = '确定') {
    return new Promise((resolve, reject) => {
      wx.showModal({
        title: title,
        content: content,
        showCancel: showCancel,
        cancelColor: '#999999',
        confirmColor: '#ff6900',
        cancelText: cancelText,
        confirmText: confirmText,
        success: res => {
          resolve(res)
        },
        fail: res => {
          resolve(res)
        }
      })
    })
  }
  
  static loading (title, mask = false) {
    wx.showLoading({
      title: title,
      mask: mask
    })
  }
  
  static hideLoading () {
    wx.hideLoading()
  }
}
